﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;

namespace RosarioFinanzas
{
    public class EnvioMails
    {
        private int EnviarMail(DataRowView mailSeleccionado, DataRow letter, int contadorBar)
        {
            try
            {
                var correo = new MailMessage { From = new MailAddress("maurojuze@gmail.com") };
                //{From = new MailAddress("info@rosariofinanzas.com.ar")};
                correo.To.Add("maurojuze@gmail.com");
                //correo.To.Add(seleccionado.Row["mail"].ToString());
                correo.Subject = letter["Asunto"].ToString();
                correo.Body = letter["Nombre"].ToString() + "\r\n" + "\r\n";
                correo.Body = correo.Body + letter["HTML"].ToString() + "\r\n";
                correo.IsBodyHtml = false;
                correo.Priority = MailPriority.Normal;
                var smtp = new SmtpClient
                {
                    Host = "smtp.gmail.com",
                    Port = 587,
                    EnableSsl = true,
                    Credentials = new NetworkCredential("maurojuze@gmail.com", "asociart**01")
                    //Host = "mail.rosariofinanzas.com.ar",
                    //Credentials = new NetworkCredential("info@rosariofinanzas.com.ar", "Info123456")
                };

                smtp.Send(correo);
                //progressBar.Value += contadorBar;
                return 1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

    }
}
